<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
const isMac = navigator.platform.indexOf('Mac') === 0;
const kBehaviors = window.internals ? ['mac', 'win'] : isMac ? ['mac'] : ['win'];
for (const behavior of kBehaviors) {
  if (window.internals) {
    internals.settings.setEditingBehavior(behavior);
    internals.settings.setSelectTrailingWhitespaceEnabled(behavior !== 'mac');
  }

selection_test(
  '<div contenteditable dir="ltr">|\n Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-0 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n| Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-1 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n |Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-2 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n J|ust\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |J^ust\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-3 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Ju|st\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |Ju^st\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-4 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Jus|t\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |Jus^t\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-5 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just|\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |Just^\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-6 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n| <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |Just\n^ <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-7 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>|testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n |Just\n^ <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-8 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>t|esting \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>|t^esting \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-9 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>te|sting \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>|te^sting \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-10 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>tes|ting \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>|tes^ting \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-11 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>test|ing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>|test^ing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-12 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testi|ng \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>|testi^ng \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-13 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testin|g \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>|testin^g \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-14 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing| \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>|testing^ \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-15 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing |\u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>|testing ^\u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-16 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8|\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing |\u05E8^\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-17 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>|\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing |\u05E8\u05E7^</span>\n \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-18 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n| \u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing |\u05E8\u05E7</span>\n^ \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-19 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n |\u05D1\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing |\u05E8\u05E7</span>\n^ \u05D1\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-20 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n \u05D1|\u05D5\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n |\u05D1^\u05D5\u05D3\u05E7\n</div>',
  `${behavior} 14-21 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5|\u05D3\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n |\u05D1\u05D5^\u05D3\u05E7\n</div>',
  `${behavior} 14-22 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3|\u05E7\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n |\u05D1\u05D5\u05D3^\u05E7\n</div>',
  `${behavior} 14-23 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7|\n</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n |\u05D1\u05D5\u05D3\u05E7^\n</div>',
  `${behavior} 14-24 ltr left word`);

selection_test(
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n \u05D1\u05D5\u05D3\u05E7\n|</div>',
  selection => selection.modify('extend', 'left', 'word'),
  '<div contenteditable dir="ltr">\n Just\n <span>testing \u05E8\u05E7</span>\n |\u05D1\u05D5\u05D3\u05E7^\n</div>',
  `${behavior} 14-25 ltr left word`);
}
</script>
